package com.imaker.action;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.imaker.domain.RoleInfo;
import com.imaker.service.RoleService;

@Controller
@Scope("prototype")
public class RoleAction extends BaseAction{

	@Autowired
	private RoleService roleService = null;
	private RoleInfo roleInfo;
	private List<RoleInfo> roleList;
	
	/**
	 * 初始化
	 * @return
	 */
	public String init(){
		
		return SUCCESS;
	}
	
	/**
	 * 列表显示
	 */
	public String list() throws Exception{
		page  = roleService.listByPage(page);
		return SUCCESS;
	}
	
	/**
	 * 预新建
	 * @return
	 */
	public String toSave(){
		
		return SUCCESS;
	}
	
	/**
	 * 新建
	 * @return
	 */
	public String save(){
		roleInfo.setCreateDate(new Date());
		roleInfo.setModifyDate(new Date());
		roleService.save(roleInfo);
		return SUCCESS;
	}
	
	/**
	 * 预修改
	 * @return
	 */
	public String toUpdate() throws Exception{
		roleInfo = roleService.findById(roleInfo.getId());
		return SUCCESS;
	}
	
	/**
	 * 修改
	 * @return
	 */
	public String update(){
		roleService.update(roleInfo);
		return SUCCESS;
	}
	
	/**
	 * 删除
	 * @return
	 */
	public String delete(){
		roleService.delete(idList);
		return SUCCESS;
	}

	public RoleService getRoleService() {
		return roleService;
	}

	public void setRoleService(RoleService roleService) {
		this.roleService = roleService;
	}

	public RoleInfo getRoleInfo() {
		return roleInfo;
	}

	public void setRoleInfo(RoleInfo roleInfo) {
		this.roleInfo = roleInfo;
	}

	public List<RoleInfo> getRoleList() {
		return roleList;
	}

	public void setRoleList(List<RoleInfo> roleList) {
		this.roleList = roleList;
	}

	
}
